// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using System;

namespace ValidationAspects.Exceptions
{
	public class ValidateLengthInRangeException : ValidationException
	{
		public static Func<ValidateLengthInRangeException, string> MessageFormat { get; set; }

		static ValidateLengthInRangeException()
		{
			ResetMessageFormat();
		}

		public ValidateLengthInRangeException(int minimum, int maximum, int value)
		{
			Minimum = minimum;
			Maximum = maximum;
			Value = value;
		}

		public static void ResetMessageFormat()
		{
			MessageFormat = e => string.Format("{0} length must be within range {1} to {2}.", e.GetValidationTargetName(), e.Minimum, e.Maximum);
		}

		public override string Message
		{
			get { return MessageFormat(this); }
		}

		public int Value { get; private set; }

		public int Minimum { get; private set; }

		public int Maximum { get; private set; }
	}
}